package com.example.ribbon.userservice.controller;

import com.example.common.api.CommonResult;
import com.example.ribbon.userservice.dto.UserDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    private Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    @PostMapping("/create")
    public CommonResult<String> create(@RequestBody UserDto userDto) {
        return CommonResult.success("操作成功");
    }

    @GetMapping("/{id}")
    public CommonResult<UserDto> getUser(@PathVariable Long id) {
        LOGGER.info("根据id获取用户信息，用户名称为：{}", "李四");
        UserDto userDto = new UserDto();
        userDto.setUsername("李四");
        userDto.setEmail("555555@qq.com");
        userDto.setIcon("/hello.png");
        userDto.setNickName("秃鹰");
        userDto.setNote("我是李四");
        userDto.setPassword("6666666");
        return CommonResult.success(userDto);
    }

    @GetMapping("/getUserByIds")
    public CommonResult<List<UserDto>> getUserByIds(@RequestParam List<Long> ids) {
        UserDto userDto = new UserDto();
        userDto.setUsername("李四");
        userDto.setEmail("555555@qq.com");
        userDto.setIcon("/hello.png");
        userDto.setNickName("秃鹰");
        userDto.setNote("我是李四");
        userDto.setPassword("6666666");
        List<UserDto> userList = new ArrayList<>();
        userList.add(userDto);

        LOGGER.info("根据ids获取用户信息，用户列表为：{}", userList);
        return CommonResult.success(userList);
    }
}